<admintpl file="header"/>
</head>
<body class="need_breadcrumb_back">
	<div class="wrap js-check-wrap">
		{:sp_get_admin_breadcrumb()}
		<form action="{:U('App/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
			<div class="row-fluid mtop20">
				<div class="span7">
					<fieldset class="width80p">
						<div class="control-group">
							<label class="control-label">APP名称</label>
							<div class="controls">
								<input type="text" name="name" value="" required>
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">APP类型</label>
							<div class="controls">
								<select name="type">
									<foreach name="types" item="type">
									<option value="{$key}">{$type}</option>
									</foreach>
								</select>
							</div>
						</div>
						<div class="control-group smallapp hide">
							<label class="control-label">小程序AppID</label>
							<div class="controls">
								<input type="text" name="small_appid" value="">
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group smallapp hide">
							<label class="control-label">小程序Secret</label>
							<div class="controls">
								<input type="text" name="small_appsecret" value="">
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">应用地址</label>
							<div class="controls">
								<input type="text" name="apk_url" value="">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">API加密</label>
							<div class="controls">
								<label class="checkbox">
								  <input type="checkbox" name="encryption" value="1"> 勾选加密
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">加密Key</label>
							<div class="controls">
								<input type="text" name="key" value="{$encryptionkey}" required>
								<span class="form-required">*</span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">应用状态</label>
							<div class="controls">
								<label class="radio inline">
								  <input type="radio" name="status" value="1" checked>
								  上架
								</label>
								<label class="radio inline">
								  <input type="radio" name="status" value="0">
								  下架
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">记录API日志</label>
							<div class="controls">
								<label class="checkbox">
								  <input type="checkbox" name="apilog" value="1"> 勾选记录日志
								</label>
							</div>
						</div>			
						<div class="control-group">
							<label class="control-label">介绍</label>
							<div class="controls">
								<textarea rows="4" name="introduce"></textarea>
								<span class="form-required">*</span>
							</div>
						</div>
					</fieldset>
				</div>
				<div class="span5"></div>
			</div>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-submit" type="submit"><i class="fa fa-save" aria-hidden="true"></i>{:L("SAVE")}</button>
				<a class="btn" href="{:U('App/index')}"><i class="fa fa-reply" aria-hidden="true"></i>{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
		$(function() {
			$('select[name=type]').on('change', function(){
				var type = $(this).children('option:selected').val();
				if(type == 5) {
					$('div.control-group.smallapp').removeClass('hide');
				} else {
					$('div.control-group.smallapp').addClass('hide');
				}
			});
			ajaxFormSubmitInit({
					'name' : {
						required : 1
					},
					'key': {
						required : 1
					},
					'introduce': {
						required: 1
					}
				}, {
					'name' : {
						required : '请输入APP名称'
					},
					'key' : {
						required : '请输入加密KEY'
					},
					'introduce': {
						required : '请输入APP介绍'
					}
				}, [{
						name : '继续添加？',
						callback : function() {
							reloadPage(window);
							return true;
						},
						focus : true
					}, {
						name : '返回列表',
						callback : function() {
							location.href = "{:U('App/index')}";
							return true;
						}
					}
	            ]
            );
		});
	</script>
</body>
</html>